/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : Divx_SubTitle.c /Project:AVOS		       **
**        Revision : 1.1                                       	**
**                                                             	**
*****************************************************************/
#include "../menu.h"
#include "Divx_SubTitleEvent.h"

INT32S WinDivx_SubTitleMsgProc_1080P(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_SHOWWINDOW:
            return WinDivx_SubTitleOnShow(hwnd, lpParam) ;
        case WM_HIDEWINDOW:
            return WinDivx_SubTitleOnHide(hwnd, lpParam) ;
	case WM_KEYDOWN:
		{
               extern char *WinMoviePlayBack ;
			PHWND hwnd = AWFindWinCtrlByName(WinMoviePlayBack);
                GUIShowWindow(WinMoviePlayBack) ;
                WinMoviePlayBackMsgProc(hwnd,msg_type, lpParam);
		}
		break;
    }
    return 0 ;
}

void SetWinDivx_SubTitlePalette_1080P(void)
{
    YUVENTRY mask_para[4] = {0, 0xfff, 0xfff, 0xfff};
    AWSetAlphaMask(0,4, mask_para);
    YUVENTRY palette_para[16] = {0x8000 | 16392,0x8000 | 22417,0x8000 | 17736,0x8000 | 17560,18168,17384,17304,15159,17127,17047,14856,16775,16392,16520,8604,16842};
    AWSetPalette(0,16, palette_para);
    return ;
}

void SetWinDivx_SubTitlePalette_4_1080P(short pattern, short background, short emphasis1, short emphasis2)
{
    YUVENTRY mask_para[4] = {0, 0xfff, 0xfff, 0xfff};
    AWSetAlphaMask(0,4, mask_para);
    YUVENTRY palette_para[16] = {0x8000 | background, pattern, emphasis1, emphasis2,18168,17384,17304,15159,17127,17047,14856,16775,16392,16520,8604,16842};
    AWSetPalette(0,4, palette_para);
    return ;
}

void SetWinDivx_SubTitlePos_1080P(HWND* pControl, INT8U CurOsdSize)
{
    switch(CurOsdSize){
        default:
            RECT StandardWindowRect1080P = {0,0,1280,1080};
            pControl->winrect = StandardWindowRect1080P;
            CREATEWINDOWPARAM StandardWindowPara_1080P = {1,{{0,0,1280,1080},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{PF_PALETTE_4,0,0,0}, SetWinDivx_SubTitlePalette_1080P};
            AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&StandardWindowPara_1080P);
            break ;
    }//end of switch
    return;
}

HWND *CreateControlWinDivx_SubTitle_1080P(HWND* pParent,INT8U CurOsdSize)
{
    HWND* pNewControl;
    switch(CurOsdSize){
        default:
            CREATEWINDOWPARAM Standardwindow_para1080P = {1,{{0,0,1280,1080},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{PF_PALETTE_4,0,0,0},SetWinDivx_SubTitlePalette_1080P};
            //Create Menu Window -- 1
            pNewControl = AWCreateWinControl("TWindow","WinDivx_SubTitle_1080P",WS_OVERLAPPEDWINDOW,
		                      0,0,1280,1080,NULL, (INT32S)&Standardwindow_para1080P,WinDivx_SubTitleMsgProc_1080P) ;
            pNewControl->win_id = 0 ;

            pNewControl = AWCreateWinControl("TControl","WinDivx_SubTitle_Control",(WS_CHILDWINDOW),
		                      358,268+48,294,134,pNewControl,0,NULL) ;
            pNewControl->win_id = 1 ;
            pNewControl->draw_info_num = 0;
            break ;
    }//end of switch
            return pNewControl;
}

HWND* CreateMenuWinDivx_SubTitle_1080P(void)
{
    HWND *pNewControl ;
    HWND *pWinDivx_SubTitle = CreateControlWinDivx_SubTitle_1080P(NULL,CurrentOsdSize);
    SetWinDivx_SubTitlePos_1080P(pWinDivx_SubTitle,CurrentOsdSize);

    return pWinDivx_SubTitle;
}

void WinResetWinDivx_SubTitleControlsPos_1080P(HWND *pControl, INT8U CurOsdSize)
{
    switch(pControl->win_id){
        case 0://WinDivx_SubTitle
            SetWinDivx_SubTitlePos_1080P(pControl,CurOsdSize) ;
            break ;
    }//end of switch
}
void WinResetWinDivx_SubTitlePos_1080P(HWND *pControl, INT8U CurOsdSize)
{
    HWND *pChildControl;
    if(pControl == NULL)
        pControl = AWFindWinCtrlByName("WinDivx_SubTitle_1080P");
    if(pControl == NULL) return ;

    WinResetWinDivx_SubTitleControlsPos_1080P(pControl, CurOsdSize) ;
    pChildControl = pControl->children ;
    while(pChildControl != NULL){
    	WinResetWinDivx_SubTitlePos_1080P(pChildControl, CurOsdSize) ;
    	pChildControl = pChildControl->siblings ;
	}
	return ;
}

